clear all

use Master2018.dta

// The data is next collapsed at the Lok Sabha overall session level

replace LS_overall = LS_overall[_n-1] if missing(LS_overall)

egen session_length = sum(LSsession), by(LS_overall)
egen break_length = sum(LSbreak), by(LS_overall)

keep if ordinances > 0

expand ordinances

sort date

gen id = _n
rename became_bill converted
gen became_bill = 1 if converted == ordinances
replace became_bill = 0 if converted == 0

/* 
The following replaces those days with more than one ordinances
that had some but not all ordinances converted into bills
*/

replace became_bill = 1 in 222
replace became_bill = 1 in 223
replace became_bill = 0 in 224
replace became_bill = 1 in 250
replace became_bill = 0 in 251
replace became_bill = 1 in 353
replace became_bill = 1 in 354
replace became_bill = 0 in 355
replace became_bill = 1 in 385
replace became_bill = 0 in 386
replace became_bill = 1 in 406
replace became_bill = 1 in 407
replace became_bill = 1 in 408
replace became_bill = 0 in 409
replace became_bill = 1 in 444
replace became_bill = 0 in 445
replace became_bill = 1 in 451
replace became_bill = 0 in 452
replace became_bill = 0 in 453
replace became_bill = 0 in 454
replace became_bill = 0 in 455
replace became_bill = 1 in 483
replace became_bill = 1 in 484
replace became_bill = 0 in 485
replace became_bill = 1 in 486
replace became_bill = 0 in 487
replace became_bill = 1 in 489
replace became_bill = 1 in 490
replace became_bill = 1 in 491
replace became_bill = 0 in 492
replace became_bill = 1 in 510
replace became_bill = 0 in 511
replace became_bill = 0 in 512
replace became_bill = 1 in 526
replace became_bill = 0 in 527
replace became_bill = 1 in 555
replace became_bill = 0 in 556
replace became_bill = 1 in 600
replace became_bill = 0 in 601

rename date date1

gen date = (date1 - 31910) / 3650

program regx, eclass
	version 14
	syntax varlist(min=2 fv) [if] [in], robust [Test(string)] [TEST2(string)] [TEST3(string)] [TEST4(string)] [YMEAN(string)] [*]
	reg `varlist' `if' `in', robust `options'
	if "`test'" != "" {
		test `test'
		ereturn local test_cmd `test'
		ereturn scalar test_p = r(p)
	}
	if "`test2'" != "" {
		test `test2'
		ereturn local test2_cmd `test2'
		ereturn scalar test2_p = r(p)
	}
	if "`test3'" != "" {
		test `test3'
		ereturn local test3_cmd `test3'
		ereturn scalar test3_p = r(p)
	}
end


gen post_1985 = 0
replace post_1985 = 1 if date1 >=31776 //Wadhwa decision 20th Dec 1986

label var post_1985 "Post 1986"
label var LSmaj "LS Majority"
label var LegisMaj "Bicameral majority"

label var yr_bef_elec "Yr before  election"
label var effectpartvote "Effective num parties"
label var cong_govt "Congress govt"
label var date "Linear time trend"

local session_ctls "break_length session_length i.sessionwithinloksabha"
local pol_ctls "yr_bef_elec effectpartvote cong_govt"

// The next 7 lines replicate the regressions in Table 6 from the paper
eststo conversion_1: reg 	became_bill LegisMaj, robust
eststo conversion_2: reg 	became_bill LegisMaj i.month_id, robust
eststo conversion_3: reg 	became_bill LegisMaj i.month_id `session_ctls', robust
eststo conversion_4: reg 	became_bill LegisMaj i.month_id `session_ctls' `pol_ctls' , robust
eststo conversion_5: reg 	became_bill LegisMaj i.month_id `session_ctls' `pol_ctls' date, robust
eststo conversion_6: logit 	became_bill LegisMaj i.month_id `session_ctls' `pol_ctls' date, robust
eststo conversion_7: probit became_bill LegisMaj i.month_id `session_ctls' `pol_ctls' date, robust


eststo LS_conversion_1: reg 	became_bill LSmaj, robust
eststo LS_conversion_2: reg 	became_bill LSmaj i.month_id, robust
eststo LS_conversion_3: reg 	became_bill LSmaj i.month_id `session_ctls', robust
eststo LS_conversion_4: reg 	became_bill LSmaj i.month_id `session_ctls' `pol_ctls' , robust
eststo LS_conversion_5: reg 	became_bill LSmaj i.month_id `session_ctls' `pol_ctls' date, robust
eststo LS_conversion_6: logit 	became_bill LSmaj i.month_id `session_ctls' `pol_ctls' date, robust
eststo LS_conversion_7: probit 	became_bill LSmaj i.month_id `session_ctls' `pol_ctls' date, robust


eststo type_conv_1: regx 	became_bill i.govt_type, robust test(1.govt_type = 2.govt_type) test2(1.govt_type = 3.govt_type) test3(2.govt_type = 3.govt_type)
eststo type_conv_2: regx 	became_bill i.govt_type `session_ctls', robust test(1.govt_type = 2.govt_type) test2(1.govt_type = 3.govt_type) test3(2.govt_type = 3.govt_type)
eststo type_conv_3: regx	became_bill i.govt_type i.month_id, robust test(1.govt_type = 2.govt_type) test2(1.govt_type = 3.govt_type) test3(2.govt_type = 3.govt_type)
eststo type_conv_4: regx 	became_bill i.govt_type i.month_id `session_ctls', robust test(1.govt_type = 2.govt_type) test2(1.govt_type = 3.govt_type) test3(2.govt_type = 3.govt_type)
eststo type_conv_5: regx 	became_bill i.govt_type i.month_id `session_ctls' `pol_ctls' , robust test(1.govt_type = 2.govt_type) test2(1.govt_type = 3.govt_type) test3(2.govt_type = 3.govt_type)
eststo type_conv_6: regx 	became_bill i.govt_type i.month_id `session_ctls' `pol_ctls' date, robust test(1.govt_type = 2.govt_type) test2(1.govt_type = 3.govt_type) test3(2.govt_type = 3.govt_type)



eststo bicam_type_conv_1: regx 	became_bill i.bicam_type, robust test(1.bicam_type = 2.bicam_type) 
eststo bicam_type_conv_2: regx 	became_bill i.bicam_type `session_ctls', robust test(1.bicam_type = 2.bicam_type) 
eststo bicam_type_conv_3: regx	became_bill i.bicam_type i.month_id, robust test(1.bicam_type = 2.bicam_type) 
eststo bicam_type_conv_4: regx 	became_bill i.bicam_type i.month_id `session_ctls', robust test(1.bicam_type = 2.bicam_type) 
eststo bicam_type_conv_5: regx 	became_bill i.bicam_type i.month_id `session_ctls' `pol_ctls' , robust test(1.bicam_type = 2.bicam_type) 
eststo bicam_type_conv_6: regx 	became_bill i.bicam_type i.month_id `session_ctls' `pol_ctls' date, robust test(1.bicam_type = 2.bicam_type) 


eststo TS_pre_conv_1: reg 		became_bill LegisMaj  if post_1985 == 0, robust
eststo TS_pre_conv_2: reg 		became_bill LegisMaj i.month_id if post_1985 == 0, robust
eststo TS_pre_conv_3: reg 		became_bill LegisMaj i.month_id `session_ctls' if post_1985 == 0, robust
eststo TS_pre_conv_4: reg 		became_bill LegisMaj i.month_id `session_ctls' `pol_ctls'  if post_1985 == 0, robust
eststo TS_pre_conv_5: reg 		became_bill LegisMaj i.month_id `session_ctls' `pol_ctls' date if post_1985 == 0, robust
eststo TS_pre_conv_6: logit 	became_bill LegisMaj i.month_id `session_ctls' `pol_ctls' date if post_1985 == 0, robust
eststo TS_pre_conv_7: probit  	became_bill LegisMaj i.month_id `session_ctls' `pol_ctls' date if post_1985 == 0, robust

eststo TS_pst_conv_1: reg 		became_bill LegisMaj  if post_1985 == 1, robust
eststo TS_pst_conv_2: reg 		became_bill LegisMaj i.month_id if post_1985 == 1, robust
eststo TS_pst_conv_3: reg 		became_bill LegisMaj i.month_id `session_ctls' if post_1985 == 1, robust
eststo TS_pst_conv_4: reg 		became_bill LegisMaj i.month_id `session_ctls' `pol_ctls'  if post_1985 == 1, robust
eststo TS_pst_conv_5: reg 		became_bill LegisMaj i.month_id `session_ctls' `pol_ctls' date if post_1985 == 1, robust
eststo TS_pst_conv_6: logit 	became_bill LegisMaj i.month_id `session_ctls' `pol_ctls' date if post_1985 == 1, robust
eststo TS_pst_conv_7: probit  	became_bill LegisMaj i.month_id `session_ctls' `pol_ctls' date if post_1985 == 1, robust


#delimit ;
local common_tab_opts
star(* 0.1 ** 0.05 *** 0.01)
varwidth(30) modelwidth(10) wrap se r2 nobase noomitted 
label numbers nodepvars
;
#delimit cr

local conversion_opts	`common_tab_opts' indicate("Month dummies = *.month_id" "Session controls = break_length session_length *.sessionwithinloksabha")

esttab conversion_*		, `conversion_opts' nomtitles 
esttab LS_conversion_*	, `conversion_opts' nomtitles
esttab type_conv_*		, `conversion_opts' nomtitles  scalar("test_p \$p\$-value \$H_0^1: \gamma_1 = \gamma_2\$" "test2_p \$p\$-value \$H_0^2: \gamma_1 = \gamma_3\$"  "test3_p \$p\$-value \$H_0^3: \gamma_2 = \gamma_3\$" ) sfmt(3)
esttab TS_pre_conv*		, `conversion_opts' nomtitles 
esttab TS_pst_conv*		, `conversion_opts' nomtitles 
esttab bicam_type_*		, `conversion_opts' nomtitles  scalar("test_p \$p\$-value \$H_0^1: \gamma_1 = \gamma_2\$") sfmt(3)
//Latex


esttab conversion_*		using "tables/conversion.tex"  , `conversion_opts' nomtitles mgroups("OLS" "OLS" "OLS" "OLS" "OLS" "Logit" "Probit", pattern(1 1 1 1 1 1 1) span prefix(\multicolumn{@span}{c}{) suffix(})) replace
esttab LS_conversion_*	using "tables/LS_conversion.tex"  , `conversion_opts' nomtitles mgroups("OLS" "OLS" "OLS" "OLS" "OLS" "Logit" "Probit", pattern(1 1 1 1 1 1 1) span prefix(\multicolumn{@span}{c}{) suffix(})) replace
esttab type_conv_*		using "tables/type_conv.tex" , `conversion_opts' nomtitles  scalar("test_p \$p\$-value \$H_0^1: \gamma_1 = \gamma_2\$" "test2_p \$p\$-value \$H_0^2: \gamma_1 = \gamma_3\$"  "test3_p \$p\$-value \$H_0^3: \gamma_2 = \gamma_3\$" ) sfmt(3) substitute(\_ _) replace

esttab TS_pre_conv*			using "tables/TS_pre_conv.tex"  , `conversion_opts' nomtitles mgroups("OLS" "OLS" "OLS" "OLS" "OLS" "Logit" "Probit", pattern(1 1 1 1 1 1 1) span prefix(\multicolumn{@span}{c}{) suffix(})) replace
esttab TS_pst_conv*			using "tables/TS_pst_conv.tex"  , `conversion_opts' nomtitles mgroups("OLS" "OLS" "OLS" "OLS" "OLS" "Logit" "Probit", pattern(1 1 1 1 1 1 1) span prefix(\multicolumn{@span}{c}{) suffix(})) replace
esttab bicam_type_conv_*	using "tables/bicam_type_conv.tex" , `conversion_opts' nomtitles  scalar("test_p \$p\$-value \$H_0^1: \gamma_1 = \gamma_2\$") sfmt(3) substitute(\_ _) replace
